#! /usr/local/bin/python3
# -*- coding: utf-8 -*-

import scrapy
import os


class QuotesSpider(scrapy.Spider):
    name = "TourSpider"


    def start_requests(self):
        urls = [
            'http://www.kanguowai.com/site/1832.html',
            'http://www.kanguowai.com/site/1833.html',
        ]
        for url in urls:
            yield scrapy.Request(url=url, callback=self.parse)

    def parse(self, response):
        page = response.url.split(".")[-2].split("/")[-1]

        filename = 'website-%s.html' % page
        with open(
                  filename, 'wb') as f:
            f.write(response.body)
        self.log('Saved file %s' % filename)

